<?php
namespace BoxAddon\Controller;

use Think\Controller;

class EmptyController extends CommonController
{
    //只能调用插件层的public方法
    /**
     * @param $name
     * @throws \Exception
     */
    public function _empty($name)
    {
        $info = parse_url($_SERVER['REQUEST_URI']);
        $url = explode("/", $info['path']);
        $addons_module = $url[2];
        $addons_class = $url[3];
        $addons_act = $url[4];
        unset($url[0]);
        unset($url[1]);
        unset($url[2]);
        unset($url[3]);
        unset($url[4]);
        $i = 1;
        $url2 = array();
        foreach ($url as $k => $one) {
            if ($one) $url2[] = $one;
        }
        if ($info['query']) {
            $query = explode("&", $info['query']);
            foreach ($query as $one) {
                $one1 = explode("=", $one);
                $url2 = array_merge($url2, $one1);
            }
        }
        foreach ($url2 as $k => $one) {
            if ($i % 2 && $one) $arg[$one] = $url2[$k + 1];
            $i++;
        }
        $this->addon_path = ADDONS_PATH . $addons_module . '/';
        $this->_static = "/Addons/" . $addons_module . "/_static";
        if (is_file($this->addon_path . 'config.php')) {
            $this->config_file = $this->addon_path . 'config.php';
            include_once($this->config_file);
        }
        $file = ADDONS_PATH . "{$addons_module}/Controller/{$addons_class}Controller.class.php";
        if (is_file($file)) {
            define('BOXADDONS', 1); // 插件名
            define('ADDON_NAME', $addons_module); // 插件名
            define('ADDON_CLASS', $addons_class); // 插件类名
            define('ADDON_METHOD', $addons_act); // 插件方法名
            hook("Auth/Check/index"); //权限控制
            // $class="Addons\\{$addons_module}\\Controller\\{$addons_class}Controller";
            if (is_array($arg)) foreach ($arg as $k => $one) $arg[$k] = urldecode($one);
            $_GET = $arg;
            hook($addons_module . "/" . $addons_class . "/" . $addons_act, $arg);
            //$obj=new $class();
            //$obj->$addons_act($_GET);
        }
        // hook(ucfirst($addons_module)."/".ucfirst($addons_class)."/".$addons_act,$arg);
    }


}